{include file="include/top"}
<style>
    td,.layui-table th{
        text-align: center;!important;
    }
    .layui-col-md12{
        display: flex;
    }
</style>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">提现管理</a>
            <a>
              <cite>审核列表</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" style="width: 100%;">
                <div class="layui-card-body ">
                    <div class="layui-row">
                        <form class="layui-form layui-col-md12 x-so" action="{:url('Cash/CashType')}" method="get">
                            <input class="layui-input" placeholder="开始日" name="start" id="start" style="width: 15%;margin: 10px 10px 10px 0px">
                            <input class="layui-input" placeholder="截止日" name="end" id="end" style="width: 15%;margin: 10px 10px 10px 0px">
                            <div style="margin: 10px 10px 10px 0px;width: 120px;">
                                <select name="city" lay-verify="required">
                                    <option value="ct_uid">用户ID</option>
                                    <option value="ct_batch">交易编号</option>
                                </select>
                            </div>
                            <input type="text" name="key"  placeholder="请输入搜索内容" autocomplete="off" class="layui-input" style="width: 15%;margin: 10px 10px 10px 0px"   >
                            <input class="layui-btn" name="sub" type="submit" value="搜索" style="margin: 10px 10px 10px 0px">
                        </form>
                    </div>
                    <table class="layui-table layui-form" >
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>交易编号</th>
                            <th>用户编号</th>
                            <th>充值金额</th>
                            <th>充值凭证</th>
                            <th>充值时间</th>
                            <th>当前状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="x-img">
                        {volist name="list" id="data"}
                        <tr>
                            <td>{$key+1}</td>
                            <td>{$data.ct_batch}</td>
                            <td>{$data.ct_uid}</td>
                            <td>{$data.ct_money}</td>
                            <td><img src="{$data.ct_img}"></td>
                            <td>{$data.ct_time|date="Y-m-d H:i:s",###}</td>
                            <td>
                                {if $data.ct_state == 0}
                                审核中...
                                {elseif $data.ct_state == 1}
                                已通过
                                {else}
                                已拒绝
                                {/if}
                            </td>
                            <td style="min-width: 106px;">
                                {if $data.ct_state == 1}
                                已通过
                                {elseif $data.ct_state == 2}
                                已拒绝
                                {else}
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="sub('{$data.ct_id}')">通过</button>
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="member_stop(this,'cash_type','ct_id','{$data.ct_id}','ct_state',2,'通过')">拒绝</button>
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
        layer.ready(function(){ //为了layer.ext.js加载完毕再执行
            layer.photos({
                photos: '#x-img'
                ,shift: 1 //0-6的选择，指定弹出图片动画类型，默认随机
            });
        });
    });
    //通过
    function sub(id) {
        $.ajax({
            type:'post',
            url:'{:url("Cash/CashTypeYes")}',
            data:{id:id},
            success: function(data){
                if(data.code>0){
                    layer.msg(data.msg,{icon:1,time:1000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                }else{
                    layer.msg(data.msg,{icon:5,time:1500});
                }
            }
        });
    }
    /*驳回*/
    function member_stop(obj,table,id,where,field,state,title){
        $.ajax({
            type: 'POST',
            url: '{:url("index/updateStatus")}',
            dataType: 'json',
            data : {table:table,id:id,where:where,field:field,state:state},
            success: function(data){
                if(data.code>0){
                    layer.msg('已'+title,{icon:1,time:1000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                }else{
                    layer.msg(title+'失败',{icon:5,time:1000});
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });
    }
</script>
</html>